<!-- 工作台页面 -->
<template>
	<view>
		<!-- 侧重部门-->
		<view class="lineClass" v-if="department_model == 1">
			<view class="line1">
				<view class="left"></view>
				<text style="margin-left: 20rpx;">侧重部门</text>
				<text style="margin-left: 220rpx;font-weight: 200;" @click="open">{{pointDepartment}}</text>
			</view>
			<!-- 部门选择弹窗 -->
			<uni-popup ref="popup" type="dialog" :mask-click="true">
				<view class="noticDetails">
					<view class="closeIcon" @click="close">
						<image style="width:52rpx;height: 52rpx;" src="../../static/images/Close_icon@2x.png"></image>
					</view>
					<view class="department" style="background-color: #CCCCCC;" @click="setDepartment('all')">
						全部
					</view>
					<view class="department" v-for="(item,index) in department_list" :key="item.department_name"
						:style="backClor + item.bg_color" @click="setDepartment(item)">
						{{item.department_name}}
					</view>

				</view>
			</uni-popup>

		</view>
		<!-- 侧重部门结束 -->
		<view class="space" v-if="department_model == 1"> </view>
		<!-- 项目模块 -->
		<view class="lineClass">
			<view class="line1">
				<view class="left"></view>
				<text style="margin-left: 20rpx;">项目</text>
			</view>

			<view class="line2">
				<view class="itemClass" v-for="(item,index) in projectList" @click="goDetails(item)" :key="item.name">
					<image class="iconClass" :src="item.src"></image>
					<view class="" style="margin-top: 10rpx;">
						{{item.name}}
					</view>
				</view>
			</view>

		</view>
		<!-- 项目模块结束 -->
		<view class="space"> </view>
		<!-- 财务模块 -->
		<view class="lineClass">
			<view class="line1">
				<view class="left"></view>
				<text style="margin-left: 20rpx;">财务</text>
			</view>

			<view class="line2">
				<view class="itemClass" v-for="(item,index) in caiwuList" @click="goDetails(item)" :key="item.name">
					<image class="iconClass" :src="item.src"></image>
					<view class="" style="margin-top: 10rpx;">
						{{item.name}}
					</view>
				</view>
			</view>
		</view>
		<!-- 财务结束 -->
		<view class="space"> </view>
		<!-- 行政 -->
		<view class="lineClass">
			<view class="line1">
				<view class="left"></view>
				<text style="margin-left: 20rpx;">行政</text>
			</view>

			<view class="line2">
				<view class="itemClass" v-for="(item,index) in adminList" @click="goDetails(item)" :key="item.name">
					<image class="iconClass" :src="item.src"></image>
					<view class="" style="margin-top: 10rpx;">
						{{item.name}}
					</view>
				</view>
			</view>
		</view>
		<!-- 行政结束 -->
		<view class="space"> </view>
		<!-- 其他 -->
		<view class="lineClass">
			<view class="line1">
				<view class="left"></view>
				<text style="margin-left: 10rpx;">其他</text>
			</view>

			<view class="line2">
				<view class="itemClass" v-for="(item,index) in otherList" @click="goDetails(item)" :key="item.name">
					<image class="iconClass" :src="item.src"></image>
					<view class="" style="margin-top: 10rpx;">
						{{item.name}}
					</view>
				</view>
			</view>
		</view>
		<!-- 其他结束 -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				backClor: 'background-color:',
				pointDepartment: '选择侧重部门', //侧重部门
				// 项目列表
				projectList: [{
						name: '项目统计',
						url: '/packageProject/pages/project/projectStat/stat',
						src: '../../static/backImg/1-1.png'
					},
					{
						name: '项目登记',
						url: '/packageProject/pages/project/projectRegist?isAdd=1',
						src: '../../static/backImg/1-2.png'
					},
					{
						name: '全部项目',
						url: '/packageProject/pages/project/projectManagement',
						src: '../../static/backImg/1-3.png'
					},
					{
						name: '业务汇报',
						url: '/packageProject/businessProject/businessProject',
						src: '../../static/backImg/ywxm.png'
					}

				],
				// 财务列表
				caiwuList: [{
						name: '财务概览',
						url: '/packageFinnace/pages/finnace/overview',
						src: '../../static/backImg/2-1.png'
					},
					{
						name: '报销',
						url: '/packageFinnace/pages/finnace/dispatch',
						src: '../../static/backImg/2-2.png'
					},
					{
						name: '项目结算',
						url: '/packageFinnace/pages/finnace/account',
						src: '../../static/backImg/2-3.png'
					},
					{
						name: '业务结算',
						url: '/packageFinnace/pages/finnace/business',
						src: '../../static/backImg/2-4.png'
					},
					{
						name: '项目专家费',
						url: '/packageFinnace/pages/finnace/expert',
						src: '../../static/backImg/2-5.png'
					},
					{
						name: '到账记录',
						url: '/packageFinnace/pages/finnace/send',
						src: '../../static/backImg/2-6.png'
					},
					{
						name: '合同登记',
						url: '/packageFinnace/pages/finnace/contract',
						src: '../../static/backImg/2-7.png'
					},
				],
				// 行政列表
				adminList: [{
						name: '邮寄',
						url: '/packageAdmin/pages/admin/post/adminPost',
						src: '../../static/backImg/3-1.png'
					},
					{
						name: '报告用章',
						url: '/packageAdmin/pages/admin/post/adminReport',
						src: '../../static/backImg/3-2.png'
					},
					{
						name: '其他用章',
						url: '/packageAdmin/pages/admin/post/adminChapter',
						src: '../../static/backImg/3-3.png'
					},
					{
						name: '合同用章',
						url: '/packageAdmin/pages/admin/post/adminContract',
						src: '../../static/backImg/1-2.png'
					},
					{
						name: '外部用章',
						url: '/packageAdmin/pages/admin/post/adminExternalSeal',
						src: '../../static/backImg/wbyz.png'
					},
					{
						name: '合同存档',
						url: '/packageAdmin/pages/admin/post/adminContractArchive',
						src: '../../static/backImg/htcd.png'
					},
					{
						name: '考勤',
						url: '/packageAdmin/pages/punchCard/punchPage',
						// url:'',
						src: '../../static/backImg/3-4.png'
					},
					{
						name: '请假申请',
						url: '/packageAdmin/pages/punchCard/attendanceApply',
						// url:'',
						src: '../../static/backImg/WechatIMG3418.png'
					},
				],
				// 其他列表
				otherList: [{
						name: '客户管理',
						url: '/pakageMessage/pages/client/client',
						src: '../../static/backImg/4-1.png'
					},
					{
						name: '知识库',
						url: '/packageChat/know/know',
						src: '../../static/backImg/4-2.png'
					},
					/* {
						name: '通讯录',
						url: '/pages/addressBook/addressBookList',
						src: '../../static/backImg/4-3.png'
					}, */
					{
						name: '水印相机',
						url: '/packageFinnace/pages/tool/carPhoto',
						src: '../../static/backImg/watermark.png'
					},
					{
						name: '外部业务',
						url: 'chat_login',
						src: '../../static/backImg/icon_chat.png'
					},
				],

				department_list: [],
				department_id: '',
				department_model: 1,
				
				wxcode:''
			}
		},
		onLoad() {

		},
		onShow() {
			this.token = uni.getStorageSync('btlh_process_token') || '';
			this.member_id = uni.getStorageSync('btlh_process_member_id') || '';
			this.company_id = uni.getStorageSync('bthl_process_LoginCompanyId') || '';
			this.department_id = uni.getStorageSync('cache_department_id') || '';
			this.pointDepartment = uni.getStorageSync('cache_department_name') || '请选择侧重部门';
			this.department_model = uni.getStorageSync('cache_department_model');
			this.getDepartment();
			
		},
		methods: {
			// 业务汇报内部登录
			async chatInLogin(){
				
				uni.setStorage({
					key: 'chat_member_id',
					data: this.member_id
				})
				
				uni.setStorage({
					key: 'chat_token',
					data: this.token
				})
				
				uni.setStorage({
					key: 'chat_is_outuser',
					data: '0'
				})
				
				uni.navigateTo({
					url:'/packageChat/GroupList/GroupList'
				})
				
			},
			
			
			// 点击设置部门
			setDepartment(val) {
				if (val == 'all') {
					this.pointDepartment = '请选择侧重部门'
					// 设置侧重部门id
					uni.setStorage({
						key: 'cache_department_id',
						data: ''
					})
					// 设置侧重部门
					uni.setStorage({
						key: 'cache_department_name',
						data: '请选择侧重部门'
					})
				} else {
					this.pointDepartment = val.department_name
					// 设置侧重部门id
					uni.setStorage({
						key: 'cache_department_id',
						data: val.department_id
					})
					// 设置侧重部门
					uni.setStorage({
						key: 'cache_department_name',
						data: val.department_name
					})
				}

				this.$refs.popup.close();
			},
			// 打开弹窗
			open() {
				this.$refs.popup.open();
			},
			// 关闭弹窗
			close() {
				this.$refs.popup.close();
			},
			// 获取部门
			async getDepartment() {
				const {
					data: res
				} = await this.$myRequest({
					url: 'Project/is_business_department',
					method: 'GET',
					data: {
						member_id: this.member_id,
						token: this.token,
						company_id: this.company_id
					}
				});
				if (res.code != 200)
					return uni.showToast({
						title: res.datas.msg,
						icon: 'none'
					});
				this.department_list = res.datas.listInfo
			},


			// 前往条目页
			goDetails(val) {
				if (val.url == '') {
					return uni.showToast({
						title: '该功能正努力完成>-<',
						icon: 'none'
					})
				}
				
				if(val.url == 'chat_login'){
					this.chatInLogin()
				}
				
				if(val.name == '通讯录'){
					return uni.switchTab({
						url:val.url
					})
				}
				uni.navigateTo({
					url: val.url
				})
			},
		}
	}
</script>

<style lang="scss">
	// 弹窗
	.noticDetails {
		background-color: #fff;
		padding: 20rpx 30rpx;
		width: 630rpx;
		border-radius: 20rpx;
		box-sizing: border-box;
		position: relative;

		.closeIcon {
			position: absolute;
			top: -70rpx;
			right: 0;
		}

		.department {
			width: 400rpx;
			height: 70rpx;
			text-align: center;
			line-height: 70rpx;
			margin-top: 20rpx;
			margin-left: 80rpx;
			border-radius: 30rpx;
			color: #FFFFFF;
		}

	}

	// 模块间隔断
	.space {
		width: 100%;
		height: 30rpx;
	}

	.lineClass {
		box-shadow: 1px 3px 15px 0px rgba(3, 70, 126, 0.2);
		padding-top: 20rpx;
		padding-bottom: 20rpx;

		.line1 {
			display: flex;
			flex-direction: row;
			align-items: center;
			font-size: 32rpx;
			font-family: PingFang SC;

			.left {
				margin-left: 40rpx;
				width: 6rpx;
				height: 42rpx;
				background: #2EB3FF;
			}
		}


		.line2 {
			display: flex;
			flex-direction: row;
			flex-wrap: wrap;
		}

		.itemClass {
			width: 135rpx;
			font-size: 24rpx;
			margin-top: 25rpx;
			margin-left: 40rpx;
			display: flex;
			flex-direction: column;
			align-items: center;
		}

		.iconClass {
			width: 70rpx;
			height: 70rpx;
			border-radius: 10rpx;

		}
	}
</style>
